#include<bits/stdc++.h>
using namespace std;
#define int long long

char ch[105][105];

signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> ch[i][j];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (ch[i][j] == '?') {
				int cnt = 0;
				for (int ki = i - 1; ki <= i + 1; ki++)
					for (int kj = j - 1; kj <= j + 1; kj++)
						if (ch[ki][kj] == '*')
							cnt++;
				ch[i][j] = '0' + cnt;
			}
			cout << ch[i][j];
		}
		cout << endl;
	}
	return 0;
}
